package ch.bfh.ti.pixelator.camera;

import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import ch.bfh.ti.pixelator.R;
import ch.bfh.ti.pixelator.R.id;

public class CameraActivity extends Activity {
	private TextView decodeInformation;
	private ProgressBar decodeProgress;
	private View rectangle;
	private View overlay;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Make the activity fullscreen
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
		setContentView(R.layout.activity_camera);
		
		// Get the with of the screen to position the overlay
		WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();
		Point size = new Point();
		display.getSize(size);
		int width = size.x;
		
		// Position the overlay
		rectangle = (View) findViewById(R.id.rectange);
		rectangle.getLayoutParams().width = width - 40;
		rectangle.getLayoutParams().height = width - 40;
		((FrameLayout.LayoutParams)rectangle.getLayoutParams()).setMargins(20, 20, 20, 20);
		
		overlay = (View) findViewById(R.id.overlay);
		((FrameLayout.LayoutParams)overlay.getLayoutParams()).setMargins(0, width, 0, 0);
		
		// Get the information views
		decodeInformation = (TextView) findViewById(R.id.decodeInformation);
		decodeProgress = (ProgressBar) findViewById(id.decodeProgressBar);
	}
	
	public void setDecodeInformation(String text) {
		decodeInformation.setText(text);
	}
	
	public void setDecodeProgress(int progress) {
		decodeProgress.setProgress(progress);
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

}
